const state = {
  // {
  //   pagePath: 'scan',
  //   text: '',
  //   iconPath: '/static/images/tab-bar/release.png',
  //   selectedIconPath: '/static/images/tab-bar/release.png',
  //   hump: true, // 是否凸起
  //   verify: false // 是否需要验证
  // },

  current: 0,
  tabBar: [
    {
      pagePath: '/home/home',
      text: '首页',
      iconPath: '/static/images/tab-bar/home.png',
      selectedIconPath: '/static/images/tab-bar/home-active.png',
      num: 0, // 角标数值
      verify: false, // 是否需要验证
      isDot: false, // 角标是否为圆点
      hump: false // 是否为凸起图标
    },
    {
      pagePath: '/scan/scan',
      text: '扫码点单',
      iconPath: '/static/images/tab-bar/scan.png',
      selectedIconPath: '/static/images/tab-bar/scan-active.png',
      num: 0, // 角标数值
      verify: false, // 是否需要验证
      isDot: false, // 角标是否为圆点
      hump: false // 是否为凸起图标
    },
    {
      pagePath: '/order/order',
      text: '订单',
      iconPath: '/static/images/tab-bar/order.png',
      selectedIconPath: '/static/images/tab-bar/order-active.png',
      num: 0, // 角标数值
      verify: false, // 是否需要验证
      isDot: false, // 角标是否为圆点
      hump: false // 是否为凸起图标
    },

    {
      pagePath: '/user/user',
      text: '我的',
      iconPath: '/static/images/tab-bar/user.png',
      selectedIconPath: '/static/images/tab-bar/user-active.png',
      num: 0, // 角标数值
      verify: false, // 是否需要验证
      isDot: false, // 角标是否为圆点
      hump: false // 是否为凸起图标
    }
  ]
}

const mutations = {
  SetTabBar: (state, tabBar) => {
    state.tabBar = tabBar
  },
  SetTabBarCurrent: (state, current) => {
    state.current = current
  },
  SetProps: (state, props) => {
    const index = props.index
    if (typeof index === undefined) return
    Object.assign(state.tabBar[index], props)
  }
}

const actions = {
  setTabBar({ commit }, tabBar) {
    commit('SetTabBar', tabBar)
  },
  setTabBarCurrent({ commit }, currentIndex) {
    commit('SetTabBarCurrent', currentIndex)
  },
  setProps({ commit }, props) {
    commit('SetProps', props)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
